//导入http模块
const http = require('http')

// 创建服务对象
const server = http.createServer((request, response) => {
    let body = ''
    request.on('data', (chunk) => {
        console.log(chunk.toString());
        body += chunk
    })
    request.on('end', () => {
        console.log(body);

        response.setHeader('Content-Type', 'text/html;charset=utf-8')
        // 设置响应体
        response.end('你好，hello world!')
    })
})

// 监听端口，启动服务
server.listen(9000, () => {
    console.log('服务启动成功...')
})